<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html  xmlns:th="http://www.thymeleaf.org">
<head>
    <title>支付宝当面付 二维码支付</title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>

    <div>
        <img src="#" alt="二维码" th:src="${session.qrcode}" />
        <input id="outTradeNo" type="hidden" th:value="${session.outTradeNo}" />
    </div>

    <div>
        <span th:text="${session.detail}"></span>
    </div>
</body>
<script src="./js/jquery-3.1.1.min.js" th:src="@{/js/jquery-3.1.1.min.js}"></script>
<script type="text/javascript">

    $(function(){
        //循环执行，每隔1秒钟执行一次 1000
        var t1 = window.setInterval(checkPayResult, 3000);
        function checkPayResult() {
            $.ajax({
                type: "GET",
                url: "/checkPayResult",
                data: {outTradeNo:$("#outTradeNo").val()},
                dataType: "json",
                success: function(data){
                    if(data.status == "TRADE_SUCCESS"){
                        window.clearInterval(t1);
                        location.href = "/page/alipay/trade_callback";
                    }else{
                        return false;
                    }
                }
            })
        }
    });

</script>
</html>